{include file="common/pc/header" title="模块列表" /}
<script>
    window.reload_when_tab_focus = true;
</script>
<style>
    #modules-table img {
        width: 60px;
        height: 60px;
    }
    #modules-table a.layui-btn {
        width: 70px;
        display: block;
        margin-right: 0px;
    }
</style>
<form action="#" class="layui-form">
    <table class="layui-table" id="modules-table">
        <colgroup>
            <col width="20">
            <col width="60">
            <col width="120">
            <col width="80">
            <col width="200">
            <col width="100">
            <col>
            <col width="150">
            <col width="250">
            <col width="200">
        </colgroup>
        <thead>
        <tr>
            <th>ID</th>
            <th>Logo</th>
            <th>模块标识</th>
            <th>版本</th>
            <th>模块名称</th>
            <th>模块状态</th>
            <th>模块介绍</th>
            <th>模块作者</th>
            <th>管理</th>
        </tr>
        </thead>
        <tbody>
        {volist name="modules" id="module"}
        <tr>
            <td>
                {if condition="isset($module['id'])"}
                {$module.id}
                {/if}
            </td>
            <td>
                <img src="/{$module.name}/logo.png" onerror="this.src='__IMAGES__/module.png';"/>
            </td>
            <td>
                {$module.name}
            </td>
            <td>
                {$module.version}
            </td>
            <td>
                {$module.title}
            </td>
            <td>
                {if condition="$module.status == 'inactive'"}
                <span class="layui-badge layui-bg-orange">未启用</span>
                {elseif condition="$module.status == 'active'"/}
                <span class="layui-badge layui-bg-green">已启用</span>
                {elseif condition="$module.status == 'uninstall' || $module.status == 'undownload'"/}
                <span class="layui-badge layui-bg-red">未安装</span>
                {/if}
            </td>
            <td>
                {$module.description}
            </td>
            <td>
                {$module.author}
                <br/>
                <a href="{$module.url}" target="_blank">{$module.url}</a>
            </td>
            <td align="center">
                <a class="layui-btn layui-btn-sm layui-btn-normal" href="javascript:;"
                   onclick="openModuleDetailTab('{$module.title}','{$module.name}')">模块管理</a>
                {if condition="$module.status == 'inactive'"}
                <a class="layui-btn layui-btn-sm layui-btn-success" href="javascript:;"
                   onclick="openModuleDetailTab('{$module.title}','{$module.name}','active')">启用模块</a>
                <a class="layui-btn layui-btn-sm layui-btn-danger" href="javascript:;"
                   onclick="openModuleDetailTab('{$module.title}','{$module.name}','uninstall')">卸载模块</a>
                {elseif condition="$module.status == 'active'"/}
                <a class="layui-btn layui-btn-sm layui-btn-warm" href="javascript:;"
                   onclick="openModuleDetailTab('{$module.title}','{$module.name}','inactive')">停用模块</a>
                {elseif condition="$module.status == 'undownload' || $module.status == 'uninstall'"/}
                <a class="layui-btn layui-btn-sm" href="javascript:;"
                   onclick="openModuleDetailTab('{$module.title}','{$module.name}','install')">安装模块</a>
                {/if}
            </td>
        </tr>
        {/volist}
        </tbody>
    </table>
</form>

<script>
    layui.use('form', function () {
        var form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功
        form.render();
    });

    function openModuleDetailTab(title, moduleName, initAction) {
        var link = "/core/site.module/detail/" + moduleName + "?init=" + initAction;
        if (window.parent && window.parent.openTab) {
            window.parent.openTab("模块管理 - " + title, link, "site_module_" + moduleName);
        } else {
            window.location.href = link;
        }
    }
</script>

{include file="common/pc/footer"/}